
import { observable ,action } from "mobx";
let mydata = [
  {
      key: '1',
      account: 'cdcms',
      userName: '罗志祥',
      department: '无',
      role: '超级管理员',
      LastLogin: '2020-04-29',
      state: '正常',
  },
  {
      key: '2',
      account: 'cdcms',
      userName: '蔡徐坤',
      department: '篮球部',
      role: '管理员',
      LastLogin: '2020-04-29',
      state: '正常',
  },
  {
      key: '3',
      account: 'cdcms',
      userName: '艾克',
      department: '时间管理部',
      role: '管理员',
      LastLogin: '2020-04-29',
      state: '正常',
  },
  
];
class ybsStore {
  @observable.ref glydata = [];
  @observable.ref  data = [];
  @action
  getglydata = ()=>{
    this.data = mydata
  }
  @action
  setglydata(obj){
    this.glydata = [...obj]
  }
  @action
  addGlyData(obj){
    let arr = []
        this.data.forEach((item)=>{
        arr.push(item.key)
    })
    let num = parseInt( arr.sort((a,b)=>{
        return b-a
    }))
    obj.key = num+1
    let allData = [...this.data]
    this.data = [...allData,obj]
    console.log(this.data);
  }
  @action
  deleteGlyData(obj){
      console.log(obj);
      let mydata = []
      this.data.forEach((item)=>{
          mydata.push(item.key)
      })
      let num = mydata.indexOf(obj.key)
      this.data.splice(num,1)
      console.log(this.data);
      
  }
}

export default ybsStore;